{% include "../common/header.html" %}
<form class="form form-horizontal" id="form-article-add">
    <input type="hidden" value="" id="aid" />
    <div class="row cl">
        <input type="hidden" value="{{item.id}}" id="tid" />
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>权限名：</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text itemname" value="{{item.pername}}" placeholder="" id="" name="">
        </div>
    </div>
    <div class="row cl">
        <input type="hidden" value="{{item.id}}" id="tid" />
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>权限路由</label>
        <div class="formControls col-xs-8 col-sm-9">
            <input type="text" class="input-text permission" value="{{item.permission}}" placeholder="" id="" name="">
        </div>
    </div>
    <div class="row cl">
        <input type="hidden" value="{{item.id}}" id="tid" />
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>所属分类</label>
        <div class="formControls col-xs-8 col-sm-9">
            <select class="" name="" id="tagSelect">
                      {% for el in tagList %}
                            <option value="{{el.id}}" {%if el.id==item.tag %}selected{%endif%} >{{el.name}}</option>
                      {%endfor%}
                </select>
        </div>
    </div>
    <div class="row cl">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
            <button class="btn btn-secondary radius" id="saveitem" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
            <button onClick="window.location.href='/{{action}}'" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
        </div>
    </div>
</form>
{% include "../common/footer.html" %}

<script>
    $("#saveitem").click(function(){
        var newData={
            id:$("#tid").val(),
            permission:$(".permission").val(),
            pername:$(".itemname").val(),
            tag:$("#tagSelect").val(),

        }
        $.ajax({
            url:'/permission/save',
            data:newData,
            type:'POST',
            success:function(json){
                if(json.errno===0){
                    alert("保存成功！");
                    window.location.href="/permission"
                }else{
                    alert(json.errmsg)
                }
            }
        })
    })



</script>
